package cn.getech.data.development.utils.ws;

import cn.getech.data.development.config.properties.BdpJobConfig;
import cn.getech.data.development.config.properties.OozieConfig;
import cn.getech.data.development.constant.LastRunState;
import cn.getech.data.development.entity.*;
import cn.getech.data.development.mapper.*;
import cn.getech.data.development.model.vo.WorkFlowStatusVO;
import cn.getech.data.development.utils.HdfsUtil;
import cn.getech.data.development.utils.oozie.JobUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.oozie.client.OozieClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.websocket.Session;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @company: getech[tcl]
 * @author: hujz
 * @Date: 2020/6/1 16:01
 * @Description: 实时查询对应的任务最新的运行状态
 */
@Slf4j
@Component
@ConditionalOnProperty(name = "data-development.websocket-open", havingValue = "true")
public class PushWorkFlowStatusUtils {

    @Autowired
    private WorkMenuJobRelMapper workMenuJobRelMapper;
    @Autowired
    private JobNodeInfoMapper jobNodeInfoMapper;
    @Autowired
    private JobInfoMapper jobInfoMapper;
    @Autowired
    private JobRunHistoryMapper jobRunHistoryMapper;
    @Autowired
    private JobNodeRunHistoryMapper jobNodeRunHistoryMapper;
    @Autowired
    private WorkFlowDepMapper workFlowDepMapper;
    @Autowired
    private JobDepRunHistoryMapper jobDepRunHistoryMapper;
    @Autowired
    private OozieConfig oozieConfig;
    @Autowired
    private BdpJobConfig bdpJobConfig;

    /***
     * 每3s推送一次数据
     */
    @Scheduled(cron = "0/3 * * * * ?")
    public void cronPushWorkFlowStatus() {
        HdfsUtil hdfsUtil = null;
        //log.info("开始推送作业流...");
        try {
            OozieClient wc = new OozieClient(oozieConfig.getUrl());
            hdfsUtil = new HdfsUtil(bdpJobConfig);
            JobUtil jobUtil = new JobUtil(hdfsUtil, wc);

            //遍历注册到这个集合中的所有的需要查询的数据
            ConcurrentHashMap<String, Session> sessionMap = WorkFlowStatusSocketServer.listSessionMap();
            Iterator<Map.Entry<String, Session>> entries = sessionMap.entrySet().iterator();
            while (entries.hasNext()) {
                Map.Entry<String, Session> entry = entries.next();
                String key = entry.getKey();
                String[] split = key.split("_");
                if(null != split && split.length >= 3){
                    String workFlowMenuIds = split[0];
                    //查询到这个菜单对应的工作流
                    try {
                        WorkMenuJobRel workMenuJobRel = workMenuJobRelMapper.selectOne(new QueryWrapper<WorkMenuJobRel>().eq("work_menu_id", workFlowMenuIds).eq("work_type", 1));
                        if (null != workMenuJobRel) {
                            WorkFlowStatusVO workFlowStatusVO = null;
                            if(StringUtils.isNotEmpty(split[1]) && !"null".equals(split[1])){
                                //直接查询对应的oozieId对应的状态
                                workFlowStatusVO = listAllJobAndJobNodeStatusByOozieId(workMenuJobRel.getWorkFlowId(),split[1]);
                            } else {
                                workFlowStatusVO = listAllJobAndJobNodeStatus(workMenuJobRel.getWorkFlowId(), jobUtil, null);
                            }
                            if (null != workFlowStatusVO) {
                                WorkFlowStatusSocketServer.sendMessage(entry.getValue(), JSONObject.toJSONString(workFlowStatusVO));
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                        log.error("push workflow status to web error:{}", e.getMessage());
                    }
                }
            }
        } catch (Exception ee) {
            log.error("push workflow status to web error:{}", ee.getMessage());
        }finally {
            if(null != hdfsUtil){
                hdfsUtil.close();
            }
        }
    }

    private WorkFlowStatusVO listAllJobAndJobNodeStatusByOozieId(Long jobInfoId,String oozieId) {
        JobInfo jobInfo = jobInfoMapper.selectById(jobInfoId);
        if(null != jobInfo){
            WorkFlowStatusVO workFlowStatusVO = new WorkFlowStatusVO();
            workFlowStatusVO.setId(Long.valueOf(jobInfo.getId()));
            JobRunHistory jobRunHistory = getJobRunOne(oozieId,jobInfoId);
            Integer jobStatus = LastRunState.NOTRUN.getCode();
            if(null != jobRunHistory){
                if (null != jobRunHistory.getState()) {
                    jobStatus = jobRunHistory.getState();
                }
            }
            //工作流是否超时、节点任务是否超时
            Integer workflowOut = 0;
            workFlowStatusVO.setStatus(jobStatus);
            if(null == jobRunHistory || StringUtils.isEmpty(jobRunHistory.getNodeParams())){
                //查询其下的节点的运行状态
                List<JobNodeInfo> jobNodeInfos = jobNodeInfoMapper.selectList(new QueryWrapper<JobNodeInfo>()
                        .eq("job_id", jobInfo.getId())
                        .isNotNull("pos_x")
                        .isNotNull("pos_y"));
                if (CollectionUtil.isNotEmpty(jobNodeInfos)) {
                    List<WorkFlowStatusVO> nodeList = new ArrayList<>();
                    for (JobNodeInfo jobNodeInfo : jobNodeInfos) {
                        Integer nodeOut = 0;
                        if(null == jobRunHistory){
                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                            workFlowStatusVO1.setId(Long.valueOf(jobNodeInfo.getId()));
                            workFlowStatusVO1.setStatus(LastRunState.NOTRUN.getCode());
                            workFlowStatusVO1.setIsOutHours(nodeOut);
                            nodeList.add(workFlowStatusVO1);
                        }else {
                            //是作业流依赖，则需要按照作业流以来的 查询方式进行查询
                            JobNodeRunHistory jobNodeRunHistory = getJobNodeRunOne(jobRunHistory.getOozieJobId(),jobNodeInfo.getId());
                            Integer jobNodeStatus = LastRunState.NOTRUN.getCode();
                            if (null != jobNodeRunHistory) {
                                if (null != jobNodeRunHistory.getState()) {
                                    jobNodeStatus = jobNodeRunHistory.getState();
                                }
                                if(null != jobNodeRunHistory.getIsOutHours()){
                                    nodeOut = jobNodeRunHistory.getIsOutHours();
                                    if(Objects.equals(1,jobNodeRunHistory.getIsOutHours())){
                                        workflowOut = 1;
                                    }
                                }
                            }
                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                            workFlowStatusVO1.setId(Long.valueOf(jobNodeInfo.getId()));
                            workFlowStatusVO1.setStatus(jobNodeStatus);
                            workFlowStatusVO1.setIsOutHours(nodeOut);
                            nodeList.add(workFlowStatusVO1);
                        }
                    }
                    workFlowStatusVO.setNodeList(nodeList);
                }
            }else {
                //解析对应的日志信息
                List<WorkFlowStatusVO> nodeList = annlyNodeParams(jobRunHistory.getNodeParams(),jobRunHistory.getOozieJobId());
                if(CollectionUtil.isNotEmpty(nodeList)){
                    workFlowStatusVO.setNodeList(nodeList);
                    long count = nodeList.stream().filter(o -> Objects.equals(1, o.getIsOutHours())).count();
                    if(count > 0){
                        workflowOut = 1;
                    }
                }
            }
            workFlowStatusVO.setIsOutHours(workflowOut);
            return workFlowStatusVO;
        }
        return null;
    }

    private JobNodeRunHistory getJobNodeRunOne(String oozieJobId, Integer jobNodeId) {
        List<JobNodeRunHistory> jobNodeRunHistories = jobNodeRunHistoryMapper.selectList(new QueryWrapper<JobNodeRunHistory>()
                .eq("oozie_job_id", oozieJobId)
                .eq("job_node_info_id", jobNodeId));
        if(CollectionUtil.isNotEmpty(jobNodeRunHistories)){
            return jobNodeRunHistories.get(0);
        }
        return null;
    }

    private JobRunHistory getJobRunOne(String oozieId, Long jobInfoId) {
        List<JobRunHistory> jobRunHistories = jobRunHistoryMapper.selectList(new QueryWrapper<JobRunHistory>()
                .eq("oozie_job_id", oozieId)
                .eq("job_info_id", jobInfoId));
        if(CollectionUtil.isNotEmpty(jobRunHistories)){
            return jobRunHistories.get(0);
        }
        return null;
    }

    private JobRunHistory getJobRunOne(String lastOozieJobId) {
        List<JobRunHistory> jobRunHistories = jobRunHistoryMapper.selectList(new QueryWrapper<JobRunHistory>()
                .eq("oozie_job_id", lastOozieJobId));
        if(CollectionUtil.isNotEmpty(jobRunHistories)){
            return jobRunHistories.get(0);
        }
        return null;
    }

    private WorkFlowStatusVO listAllJobAndJobNodeStatus(Long jobInfoId, JobUtil jobUtil, String depOozieId) {
        JobInfo jobInfo = jobInfoMapper.selectById(jobInfoId);
        if (null != jobInfo) {
            WorkFlowStatusVO workFlowStatusVO = new WorkFlowStatusVO();
            workFlowStatusVO.setId(Long.valueOf(jobInfo.getId()));
            //查询job最近的一笔的状态
            JobRunHistory sumJobRunHistory = null;
            if (StringUtils.isEmpty(depOozieId)) {
                //是工作流日志
                JobRunHistory jobRunHistory = null, corJobRunHistory = null;
                if (StringUtils.isNotEmpty(jobInfo.getLastOozieJobId())) {
                    jobRunHistory =  getJobRunOne(jobInfo.getLastOozieJobId());
                }
                if (StringUtils.isNotEmpty(jobInfo.getLastCorOozieJobId()) && null != jobInfo.getLastRunNum()) {
                    String oozieWorkFlowId = null;
                    try {
                        oozieWorkFlowId = jobUtil.getWorkFlowID(jobInfo.getLastCorOozieJobId(), jobInfo.getLastRunNum());
                    } catch (Exception e) {
                        //log.error("获取调度对应的编号异常,corOOzieId:{},lastNum:{},error:{}", jobInfo.getLastCorOozieJobId(), jobInfo.getLastRunNum(), e.getMessage());
                    }
                    if (StringUtils.isNotEmpty(oozieWorkFlowId)) {
                        corJobRunHistory = getJobRunOne(oozieWorkFlowId);
                    }
                }
                if (null != jobRunHistory && null != corJobRunHistory) {
                    if (jobRunHistory.getId() > corJobRunHistory.getId()) {
                        sumJobRunHistory = jobRunHistory;
                    } else {
                        sumJobRunHistory = corJobRunHistory;
                    }
                } else if (null != jobRunHistory) {
                    sumJobRunHistory = jobRunHistory;
                } else if (null != corJobRunHistory) {
                    sumJobRunHistory = corJobRunHistory;
                }
            } else {
                //查询作业流依赖的日志信息
                sumJobRunHistory = getJobRunDepOne(depOozieId,jobInfoId);

            }
            Integer jobStatus = LastRunState.NOTRUN.getCode();
            if (null != sumJobRunHistory) {
                if (null != sumJobRunHistory.getState()) {
                    jobStatus = sumJobRunHistory.getState();
                }
            }
            workFlowStatusVO.setStatus(jobStatus);
            //工作流是否超时
            Integer workflowOut = 0;
            //查询其下的节点的运行状态
            if(null == sumJobRunHistory || StringUtils.isEmpty(sumJobRunHistory.getNodeParams())){
                List<JobNodeInfo> jobNodeInfos = jobNodeInfoMapper.selectList(new QueryWrapper<JobNodeInfo>().eq("job_id", jobInfo.getId()).isNotNull("pos_x").isNotNull("pos_y"));
                if (CollectionUtil.isNotEmpty(jobNodeInfos)) {
                    List<WorkFlowStatusVO> nodeList = new ArrayList<>();
                    for (JobNodeInfo jobNodeInfo : jobNodeInfos) {
                        Integer nodeOut = 0;
                        //对应的oozieId对应的运行状态
                        if (null == sumJobRunHistory) {
                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                            workFlowStatusVO1.setId(Long.valueOf(jobNodeInfo.getId()));
                            workFlowStatusVO1.setStatus(LastRunState.NOTRUN.getCode());
                            workFlowStatusVO1.setIsOutHours(nodeOut);
                            nodeList.add(workFlowStatusVO1);
                        } else {
                            //是作业流依赖，则需要按照作业流以来的 查询方式进行查询
                            JobNodeRunHistory jobNodeRunHistory = getJobNodeRunOne(sumJobRunHistory.getOozieJobId(),jobNodeInfo.getId());
                            Integer jobNodeStatus = LastRunState.NOTRUN.getCode();
                            if (null != jobNodeRunHistory) {
                                if (null != jobNodeRunHistory.getState()) {
                                    jobNodeStatus = jobNodeRunHistory.getState();
                                }
                                if(null != jobNodeRunHistory.getIsOutHours()){
                                    nodeOut = jobNodeRunHistory.getIsOutHours();
                                    if(Objects.equals(1,jobNodeRunHistory.getIsOutHours())){
                                        workflowOut = 1;
                                    }
                                }
                            }
                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                            workFlowStatusVO1.setId(Long.valueOf(jobNodeInfo.getId()));
                            workFlowStatusVO1.setStatus(jobNodeStatus);
                            workFlowStatusVO1.setIsOutHours(nodeOut);
                            nodeList.add(workFlowStatusVO1);
                        }
                    }
                    workFlowStatusVO.setNodeList(nodeList);
                }
            }else{
                //解析对应的日志信息
                List<WorkFlowStatusVO> nodeList = annlyNodeParams(sumJobRunHistory.getNodeParams(),sumJobRunHistory.getOozieJobId());
                if(CollectionUtil.isNotEmpty(nodeList)){
                    workFlowStatusVO.setNodeList(nodeList);
                    long count = nodeList.stream().filter(o -> Objects.equals(1, o.getIsOutHours())).count();
                    if(count > 0){
                        workflowOut = 1;
                    }
                }
            }
            workFlowStatusVO.setIsOutHours(workflowOut);
            return workFlowStatusVO;
        }
        return null;
    }

    private JobRunHistory getJobRunDepOne(String depOozieId, Long jobInfoId) {
        List<JobRunHistory> jobRunHistories = jobRunHistoryMapper.selectList(new QueryWrapper<JobRunHistory>()
                .eq("dep_oozie_job_id", depOozieId).eq("job_info_id", jobInfoId));
        if(CollectionUtil.isNotEmpty(jobRunHistories)){
            return jobRunHistories.get(0);
        }
        return null;
    }


    /***
     * 每3s推送一次数据
     */
    @Scheduled(cron = "0/4 * * * * ?")
    public void cronPushWorkFlowLayStatus() {
        //log.info("开始推送作业流依赖...");
        try {
            //遍历注册到这个集合中的所有的需要查询的数据
            ConcurrentHashMap<String, Session> sessionMap = WorkFlowLayStatusSocketServer.listSessionMap();
            Iterator<Map.Entry<String, Session>> entries = sessionMap.entrySet().iterator();
            while (entries.hasNext()) {
                Map.Entry<String, Session> entry = entries.next();
                String key = entry.getKey();
                String[] split = key.split("_");
                if(null != split && split.length >= 3) {
                    String workFlowMenuIds = split[0];
                    //查询到这个菜单对应的工作流依赖
                    try {
                        WorkFlowDep workFlowDep = workFlowDepMapper.selectOne(new QueryWrapper<WorkFlowDep>().eq("work_menu_id", workFlowMenuIds));
                        if (null != workFlowDep) {
                            WorkFlowStatusVO workFlowStatusVO = new WorkFlowStatusVO();
                            workFlowStatusVO.setId(workFlowDep.getId());
                            //查询到最近的一条工作流依赖
                            JobDepHistory jobDepHistory = null;
                            if(StringUtils.isNotEmpty(split[1]) && !"null".equals(split[1])){
                                //直接查询到对应的记录
                                jobDepHistory = getJobDepOne(split[1],workFlowDep.getId());
                            }else {
                                jobDepHistory = jobDepRunHistoryMapper.selecetByIdOne(workFlowDep.getId());
                            }
                            Integer jobDepStatus = LastRunState.NOTRUN.getCode();
                            if (null != jobDepHistory && null != jobDepHistory.getState()) {
                                jobDepStatus = jobDepHistory.getState();
                            }
                            workFlowStatusVO.setStatus(jobDepStatus);
                            Integer workflowLayOut = 0;
                            //查询其下的工作流和对应的状态
                            if(null == jobDepHistory || StringUtils.isEmpty(jobDepHistory.getNodeParams())){
                                List<WorkMenuJobRel> workMenuJobRels = workMenuJobRelMapper.selectList(new QueryWrapper<WorkMenuJobRel>().eq("work_menu_id", workFlowMenuIds).eq("work_type", 2));
                                if (CollectionUtil.isNotEmpty(workMenuJobRels)) {
                                    List<WorkFlowStatusVO> nodeList = new ArrayList<>();
                                    for (WorkMenuJobRel workMenuJobRel : workMenuJobRels) {
                                        //用一个错误的oozieId去查询其状态，查询不到则为未启动状态
                                        String jobDepOozieId = "111-222-333";
                                        if (null != jobDepHistory && StringUtils.isNotEmpty(jobDepHistory.getOozieJobId())) {
                                            jobDepOozieId = jobDepHistory.getOozieJobId();
                                        }
                                        WorkFlowStatusVO workFlowStatusVO1 = listAllJobAndJobNodeStatus(workMenuJobRel.getWorkFlowId(), null, jobDepOozieId);
                                        if (null != workFlowStatusVO1) {
                                            nodeList.add(workFlowStatusVO1);
                                            long count = nodeList.stream().filter(o -> Objects.equals(1, o.getIsOutHours())).count();
                                            if(count > 0){
                                                workflowLayOut = 1;
                                            }
                                        }
                                    }
                                    workFlowStatusVO.setNodeList(nodeList);
                                }
                            }else{
                                //查询对应的历史的工作流依赖节点
                                List<WorkFlowStatusVO> nodeList = annlyJobAndNodeParams(jobDepHistory.getNodeParams(),jobDepHistory.getOozieJobId());
                                if(CollectionUtil.isNotEmpty(nodeList)){
                                    workFlowStatusVO.setNodeList(nodeList);
                                    long count = nodeList.stream().filter(o -> Objects.equals(1, o.getIsOutHours())).count();
                                    if(count > 0){
                                        workflowLayOut = 1;
                                    }
                                }

                            }
                            workFlowStatusVO.setIsOutHours(workflowLayOut);
                            WorkFlowLayStatusSocketServer.sendMessage(entry.getValue(), JSONObject.toJSONString(workFlowStatusVO));
                        }
                    }catch (Exception ee){
                        ee.printStackTrace();
                        log.error("push workflowLay status to web error:{}", ee.getMessage());
                    }
                }
            }
        } catch (Exception e) {
            log.error("push workflowLay status to web error:{}", e.getMessage());
        }
    }

    private JobDepHistory getJobDepOne(String oozieId, Long depId) {
        List<JobDepHistory> jobDepHistories = jobDepRunHistoryMapper.selectList(new QueryWrapper<JobDepHistory>()
                .eq("oozie_job_id", oozieId)
                .eq("job_dep_id", depId));
        if(CollectionUtil.isNotEmpty(jobDepHistories)){
            return jobDepHistories.get(0);
        }
        return null;
    }

    private List<WorkFlowStatusVO> annlyJobAndNodeParams(String nodeParams, String oozieJobId) {
        if(StringUtils.isNotEmpty(nodeParams)){
            try {
                JSONObject jsonObject = JSONObject.parseObject(nodeParams);
                if(null != jsonObject){
                    Object nodes = jsonObject.get("nodes");
                    if(null != nodes){
                        JSONArray jsonArray = JSONArray.parseArray(nodes.toString());
                        if(null != jsonArray){
                            //遍历每一个节点，并且和oozieId查询到对应的节点的状态数据
                            List<WorkFlowStatusVO> nodeList = new ArrayList<>();
                            for (Object o : jsonArray) {
                                if(null != o){
                                    JSONObject obj = JSONObject.parseObject(o.toString());
                                    if(null != obj){
                                        Object id = obj.get("id");
                                        if(null != id){
                                            Integer status = LastRunState.NOTRUN.getCode();
                                            Integer workflowOut = 0;
                                            List<WorkFlowStatusVO> workFlowStatusVOS = new ArrayList<>();
                                            if(StringUtils.isNotEmpty(oozieJobId)){
                                                JobRunHistory one = getJobRunDepOne(oozieJobId,Long.valueOf(id.toString()));
                                                if(null != one){
                                                    status = one.getState();
                                                    //查询其下节点的状态，并且返回
                                                    List<WorkFlowStatusVO> workFlowStatusVOS1 = annlyNodeParams(one.getNodeParams(), one.getOozieJobId());
                                                    if(CollectionUtil.isNotEmpty(workFlowStatusVOS1)){
                                                        workFlowStatusVOS.addAll(workFlowStatusVOS1);
                                                        long count = workFlowStatusVOS.stream().filter(o1 -> Objects.equals(1, o1.getIsOutHours())).count();
                                                        if(count > 0){
                                                            workflowOut = 1;
                                                        }
                                                    }
                                                }else{
                                                    //查询其子节点并且返回结果
                                                    List<JobNodeInfo> jobNodeInfos = jobNodeInfoMapper.selectList(new QueryWrapper<JobNodeInfo>().eq("job_id", id).isNotNull("pos_x").isNotNull("pos_y"));
                                                    if(CollectionUtil.isNotEmpty(jobNodeInfos)){
                                                        for (JobNodeInfo jobNodeInfo : jobNodeInfos) {
                                                            WorkFlowStatusVO workFlowStatusVO3 = new WorkFlowStatusVO();
                                                            workFlowStatusVO3.setId(Long.valueOf(jobNodeInfo.getId()));
                                                            workFlowStatusVO3.setStatus(status);
                                                            workFlowStatusVO3.setIsOutHours(0);
                                                            workFlowStatusVOS.add(workFlowStatusVO3);
                                                        }
                                                    }
                                                }
                                            }
                                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                                            workFlowStatusVO1.setId(Long.valueOf(id.toString()));
                                            workFlowStatusVO1.setStatus(status);
                                            workFlowStatusVO1.setNodeList(workFlowStatusVOS);
                                            workFlowStatusVO1.setIsOutHours(workflowOut);
                                            nodeList.add(workFlowStatusVO1);
                                        }
                                    }
                                }
                            }
                            return nodeList;
                        }
                    }
                }
            }catch (Exception e){
                log.error("解析作业流依赖的日志信息异常！error:{}",e.getMessage());
            }
        }
        return null;
    }

    private List<WorkFlowStatusVO> annlyNodeParams(String nodeParams,String oozieId) {
        if(StringUtils.isNotEmpty(nodeParams)){
            try {
                JSONObject jsonObject = JSONObject.parseObject(nodeParams);
                if(null != jsonObject){
                    Object nodes = jsonObject.get("nodes");
                    if(null != nodes){
                        JSONArray jsonArray = JSONArray.parseArray(nodes.toString());
                        if(null != jsonArray){
                            //遍历每一个节点，并且和oozieId查询到对应的节点的状态数据
                            List<WorkFlowStatusVO> nodeList = new ArrayList<>();
                            for (Object o : jsonArray) {
                                if(null != o){
                                    JSONObject obj = JSONObject.parseObject(o.toString());
                                    if(null != obj){
                                        Object id = obj.get("id");
                                        if(null != id){
                                            Integer status = LastRunState.NOTRUN.getCode();
                                            Integer outHours = 0;
                                            if(StringUtils.isNotEmpty(oozieId)){
                                                JobNodeRunHistory one =  getJobNodeRunOne(oozieId,Integer.valueOf(id.toString()));
                                                if(null != one){
                                                    status = one.getState();
                                                    if(Objects.equals(1,one.getIsOutHours())){
                                                        outHours = one.getIsOutHours();
                                                    }
                                                }
                                            }
                                            WorkFlowStatusVO workFlowStatusVO1 = new WorkFlowStatusVO();
                                            workFlowStatusVO1.setId(Long.valueOf(id.toString()));
                                            workFlowStatusVO1.setStatus(status);
                                            workFlowStatusVO1.setIsOutHours(outHours);
                                            nodeList.add(workFlowStatusVO1);
                                        }
                                    }
                                }
                            }
                            return nodeList;
                        }
                    }
                }
            }catch (Exception e){
                log.error("解析日志信息异常！error:{}",e.getMessage());
            }
        }
        return null;
    }

}
